/**
 * 公交车站的距离
 *
 * @USER: Administrator
 * @DATE: 2024/9/23 下午10:21
 * @VERSION: 1.0.0
 */
public class LC1184 {
    public static void main(String[] args) {
        LC1184 lc1184 = new LC1184();
        System.out.println(lc1184.distanceBetweenBusStops(new int[]{7,10,1,12,11,14,5,0},7,2));
    }
    public int distanceBetweenBusStops(int[] distance, int start, int destination) {
        int sum = 0;
        int dist = 0;
        for (int i = 0; i < distance.length; i++) {
            sum += distance[i];
            if (i>=Math.min(start,destination) && i<Math.max(start,destination)) {
                dist += distance[i];
            }
        }
        return Math.min(dist,sum-dist);
    }
}
